


#ifndef MSG_BUFFER_H 

#define MSG_BUFFER_H

#include "Telematics.h"
//----------------------------------------------------------------------------
// msgbuf.h                                                                  
//----------------------------------------------------------------------------


// Class for handling message buffers. The access for the message buffer values is done by get/set functions using iterators.
//## class msgbuf 
class msgbuf  {


////    Constructors and destructors    ////
public :
    
    // Argument uint32_t size : 
    // Initial size of the message buffer.
    //## operation msgbuf(uint8_t*,uint32_t) 
    msgbuf(uint8_t* buffer, uint32_t size);
    
    msgbuf();
    
    virtual ~msgbuf();


////    Operations    ////
public :
    
    // Dumps the message to trace.
    //## operation dumpMsg(uint16_t,uint16_t) 
    void dumpMsg(uint16_t startIndex, uint16_t length);
    
    // Gets the nth byte of the buffer.
    //## operation getByte(uint16_t) const 
    uint8_t getByte(uint16_t index) const;
    
    // Copies the message buffer data into the given buffer.
    //## operation getData(uint8_t*,uint16_t) 
    BOOL getData(uint8_t* buffer, uint16_t size);

	//## operation getData(uint8_t*,uint16_t) 
    BOOL getBufData(uint8_t* buffer, uint16_t size);
    
    // Returns the maximum size of the message buffer.
    //## operation getMaxSize() const 
    uint32_t getMaxSize() const;
    
    // Returns the pointer to the message buffer.
    //## operation getMsgBuffer const() 
    uint8_t* getMsgBuffer ()const;
    
    // Returns the actual size of the message buffer.
    //## operation getSize() const 
    uint32_t getSize() const;
    
    // Function for getting a value from the message buffer. The iterator is increased after a successful reading.
    //## operation getValue(uint8_t) 
    BOOL getValue(uint8_t& data);

	uint8_t* getCurPtr() const;
    
    // Initializing function. Sets the iterator to 0 and fills the message buffer with 0 bytes.
    //## operation init() 
    void init();
    
    //## operation reset() 
    void reset();

	// Fills the message buffer with the given data.
	//## operation setData(uint8_t*,uint16_t) 
    BOOL initData(uint8_t* buffer, uint16_t size);
        
    //## operation setData(uint8_t*,uint16_t) 
    BOOL setData(uint8_t* buffer, uint16_t size);
    
    // Function for setting the next value in the message buffer. The iterator is increased after a successful writing.
    //## operation setValue(uint8_t) 
    BOOL setValue(uint8_t data);

	//## auto_generated 
    uint32_t getMsgBufferSize() const;
    
    //## auto_generated 
    void setMsgBufferSize(uint32_t p_msgBufferSize);

	void setMsgBufferPtr(uint8_t * p_msgBufferPtr);
	BOOL msgbuf::GetFiledContent(uint8_t sep, msgbuf& buf);
	BOOL msgbuf::IsReachEnd() const;


////    Additional operations    ////

    
    


////    Attributes    ////
protected :
    
    // Iterator for the message buffer. Shows the actual offset where the read/write instruction will take place.
    uint32_t msgBufferIterator;		//## attribute msgBufferIterator 
    
    // Message buffer pointer for messages.
    uint8_t* msgBufferPtr;		//## attribute msgBufferPtr 
    
    // The size of the message buffer. Must be set before usage.
    uint32_t msgBufferSize;		//## attribute msgBufferSize 
    

};


#endif  

